<template>
  <div class="com-a">
    <h2>A组件</h2>
    <p>从B组件中传过来的数据:{{msg}}</p>
  </div>
</template>

<script>
import eventBus from "@/eventBus";
export default {
  name: "com-a",
  data() {
    return {
      msg: ""
    };
  },
  created() {
    // 接收数据
    eventBus.$on("BtoA", data => {
      this.msg = data;
    });
  }
};
</script>

